const { Comment } = require('../../model/comment');
module.exports = async (req,res)=>{
  let comment = await Comment.findOne({_id: req.query.id});
  if (comment){
    if(comment.state == 1 ){
      await Comment.findByIdAndUpdate(req.query.id,{
        state: 0
      });
      res.redirect('/admin/toCommentListPage');
    }else if(comment.state == 0){
      await Comment.findByIdAndUpdate(req.query.id,{
        state: 1
      });
      res.redirect('/admin/toCommentListPage');
    }
  }else{
    res.render('admin/commentList',{
      message: '修改评论状态失败！！！'
    });
  }
}